home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8994 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!seacloud.demon.co.uk
  2. From: Ben Ashley <Ben@seacloud.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: QUESTION:Random Numbers, etc
  5. Date: Tue, 27 Feb 96 16:17:25 GMT
  6. Organization: home, in Leicester, England
  7. Message-ID: <825437845snz@seacloud.demon.co.uk>
  8. References: <4gnpic$j5s@news1.usa.pipeline.com> <4gr0hs$qck@masala.cc.uh.edu>
  9. Reply-To: Ben@seacloud.demon.co.uk
  10. X-NNTP-Posting-Host: seacloud.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.29
  12. X-Mail2News-Path: seacloud.demon.co.uk
  13.  
  14. In article <4gr0hs$qck@masala.cc.uh.edu> txs53132@bayou.uh.edu "Sensarn" writes:
  15.  
  16. > The actual BASIC formula (figured this one out myself) is:
  17. > INT(RND*(MAX-MIN+1)+MIN)
  18. > The TC++ 3.1 function random() can be used to generate a similar effect:
  19. > random(max-min+1)+min;
  20. > Hope VC++ has random()!
  21.  
  22. I use MSVC 1.00.  It does not have random(), but it has rand() which generates
  23. a stupid number!  To get it in a range, you have to use the modulus '%'
  24. operator.
  25.  
  26. To get a number between 1 and 16, you use 'rand() % 17'.  Or something like
  27. that anyway!
  28.  
  29. -- 
  30. Cheers,
  31.  
  32. Ben
  33.  
  34. ------------------====### legal notice ###====-----------------------
  35. Microsoft Network is prohibited from redistributing this work in any
  36. form,in whole or in part.  License to distribute this post is available to
  37. Microsoft for $499.  Posting without permission constitutes an agreement to
  38. these terms.
  39.